#include <iostream>
#include <memory>

class Entity{
public:
    Entity() 
    {
        std::cout << "Created Entity!" << std::endl;
    }

    ~Entity()
    {
        std::cout << "Destoryed Entity!" << std::endl;
    }

    void print() {}
};

int main()
{
    {
        //unique_ptr 不直接调用new，是因为异常安全,shared_ptr 是因为需要分配一块内存，叫做控制块，用来存储引用计数。
       std::unique_ptr<Entity> uniqueEntity = std::make_unique<Entity>(); //make_unique since c++14
       uniqueEntity->print();
    }
        
    {
        std::shared_ptr<Entity> sharedEntity = std::make_shared<Entity>();
        std::weak_ptr<Entity> weakEntity = shared;
    }    
}